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
c10ca91b91b4f816cc21bdf968fc9fe5
train_002.jsonl
1557844500
You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class E{ final int mod = 998244353; final int maxn = -1; final double eps = 1e-9; void main(){ // freopen("in"); int n = nextInt(); List<Long> a = new ArrayList<Long>(); for(int i = 0; i < n; ++i){ a.add((long)(i + 1) * (n ...
Java
["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"]
2 seconds
["646", "757402647", "20"]
null
Java 8
standard input
[ "sortings", "greedy", "math" ]
93431bdae447bb96a2f0f5fa0c6e11e0
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of...
1,600
Print one integer β€” the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder.
standard output
PASSED
588179f7c7bf2ae6d286d6f3d40eb723
train_002.jsonl
1557844500
You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$...
256 megabytes
import java.util.*; //1165E public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); Long[] A=new Long[n]; Long[] B=new Long[n]; for(int i=0;i<n;i++) A[i]=sc.nextLong(); for(int i=0;i<n;i++) B[i]=sc.nextLong(); ...
Java
["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"]
2 seconds
["646", "757402647", "20"]
null
Java 8
standard input
[ "sortings", "greedy", "math" ]
93431bdae447bb96a2f0f5fa0c6e11e0
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of...
1,600
Print one integer β€” the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder.
standard output
PASSED
281109d02840f81e2a9d312ebd9726a0
train_002.jsonl
1557844500
You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$...
256 megabytes
import javafx.scene.layout.Priority; import java.io.*; import java.lang.reflect.Array; import java.net.Inet4Address; import java.util.*; import java.lang.*; import java.util.HashMap; import java.util.PriorityQueue; public class templ implements Runnable { static class pair implements Comparable { int f;...
Java
["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"]
2 seconds
["646", "757402647", "20"]
null
Java 8
standard input
[ "sortings", "greedy", "math" ]
93431bdae447bb96a2f0f5fa0c6e11e0
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of...
1,600
Print one integer β€” the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder.
standard output
PASSED
36dea4ed1ab825c9346e0aa8fddee815
train_002.jsonl
1557844500
You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$...
256 megabytes
import java.io.*; import java.text.*; import java.util.*; import java.math.*; public class template { public static void main(String[] args) throws Exception { new template().run(); } public void run() throws Exception { FastScanner f = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n ...
Java
["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"]
2 seconds
["646", "757402647", "20"]
null
Java 8
standard input
[ "sortings", "greedy", "math" ]
93431bdae447bb96a2f0f5fa0c6e11e0
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of...
1,600
Print one integer β€” the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder.
standard output
PASSED
37b51391577fc60767aabe966f2d09cb
train_002.jsonl
1557844500
You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { public static void main(String[] args) throws IOException { PrintWriter out = new PrintWriter(System.out); //Scanner sc = new Scanner(); Reader in = new Reader(); Main solver = new Main(); solver....
Java
["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"]
2 seconds
["646", "757402647", "20"]
null
Java 8
standard input
[ "sortings", "greedy", "math" ]
93431bdae447bb96a2f0f5fa0c6e11e0
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of...
1,600
Print one integer β€” the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder.
standard output
PASSED
5482e3a93bb0c43389e7dde74f06fc6e
train_002.jsonl
1557844500
You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$...
256 megabytes
import java.io.*; import java.math.*; import java.text.*; import java.util.*; import java.util.regex.*; public class Solution { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter w = new PrintWriter(S...
Java
["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"]
2 seconds
["646", "757402647", "20"]
null
Java 8
standard input
[ "sortings", "greedy", "math" ]
93431bdae447bb96a2f0f5fa0c6e11e0
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of...
1,600
Print one integer β€” the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder.
standard output
PASSED
a912df836bfddeb392e227a3d896e139
train_002.jsonl
1557844500
You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$...
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.*; public class TaskE { int n; Integer[] a, b; static long MOD = 998244353; void solve() throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)...
Java
["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"]
2 seconds
["646", "757402647", "20"]
null
Java 8
standard input
[ "sortings", "greedy", "math" ]
93431bdae447bb96a2f0f5fa0c6e11e0
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of...
1,600
Print one integer β€” the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder.
standard output
PASSED
e8a5283a6c6e26b7af1e3a8c366769bc
train_002.jsonl
1557844500
You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$...
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.*; public class TaskE { int n; Integer[] a, b; static long MOD = 998244353; void solve() throws Exception { Scanner sc = new Scanner(System.in); n = sc.nextInt(); ...
Java
["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"]
2 seconds
["646", "757402647", "20"]
null
Java 8
standard input
[ "sortings", "greedy", "math" ]
93431bdae447bb96a2f0f5fa0c6e11e0
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of...
1,600
Print one integer β€” the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder.
standard output
PASSED
5d61cf5c502031ac606cf7dc79980137
train_002.jsonl
1557844500
You are given two arrays $$$a$$$ and $$$b$$$, both of length $$$n$$$.Let's define a function $$$f(l, r) = \sum\limits_{l \le i \le r} a_i \cdot b_i$$$.Your task is to reorder the elements (choose an arbitrary order of elements) of the array $$$b$$$ to minimize the value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$...
256 megabytes
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.*; public class TaskE { int n; ArrayList<Integer> a, b; static long MOD = 998244353; void solve() throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(S...
Java
["5\n1 8 7 2 4\n9 7 2 9 3", "1\n1000000\n1000000", "2\n1 3\n4 2"]
2 seconds
["646", "757402647", "20"]
null
Java 8
standard input
[ "sortings", "greedy", "math" ]
93431bdae447bb96a2f0f5fa0c6e11e0
The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) β€” the number of elements in $$$a$$$ and $$$b$$$. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$. The third line of...
1,600
Print one integer β€” the minimum possible value of $$$\sum\limits_{1 \le l \le r \le n} f(l, r)$$$ after rearranging elements of $$$b$$$, taken modulo $$$998244353$$$. Note that you should minimize the answer but not its remainder.
standard output
PASSED
2c68a3350dec4ae9c14c4754945cc663
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
import java.io.*; import java.math.*; import java.security.KeyStore.Entry; import java.util.*; public class CODEFORCES { private InputStream is; private PrintWriter out; class ST { int n; int arr[]; ST(int a) { n = a; arr = new int[n + 1]; } void u(int ind, int val) { ind++; while (ind <= n...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
747c749f873c8e564376337376ce676b
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.Collection; import java.util.Random; import java.io.Writer; import java.io.OutputStreamWriter; import jav...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
a9c32b9c82c580bd4b3c686d59f3e390
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /** * Built using CHelper plug-in ...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
9afabc7b149939dfde183ba2d791888c
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
import java.util.*; import java.io.*; public class E { public static int sqrt, maxn, bit[][], arr[]; public static void main(String[] args) throws Exception { InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); int n = in.nextInt(); int q = ...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
84588a773338427dce4b64c8b3b30004
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
import java.io.*; import java.util.*; public class InversionNSqrtNNoVectors { private static final int BLOCK_SZ_Q = 256; private static final int BLOCK_SZ_N = 512; public static class ToProcess { public int x, y1, y2, sgn, id; public void set(int pX, int pY1, int pY2, int pSgn, int pId) { x = pX; y1 ...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
6009a539b74172106fd2df2ee3f54a2d
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
import java.io.*; import java.util.*; public class InversionNSqrtNNoVectors { private static final int BLOCK_SZ_Q = 256; private static final int BLOCK_SZ_N = 512; public static class ToProcess { public int x, y1, y2, sgn, id; public void set(int pX, int pY1, int pY2, int pSgn, int pId) { x = pX; y1 ...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
99e9e1079b4fd9284b614d10741f1bf7
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 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 AntonPermutation { int n, q, b, m; int[] a; int[][] bit; void solve() { n = in.nextInt...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
f7e252bcede8296881af71295d5e036b
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
import java.util.*; import java.io.*; import java.math.BigInteger; /** * * @author usquare */ public class E785 { static int mod = (int) (1e9+7); static InputReader in; static PrintWriter out; static int[][] bit; static void update(int ind,int i,int d){ for(;i<bit[ind].length...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
2688ce44c33c88a54e60ff5e692b368d
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
import java.io.*; import java.util.*; public class CF785E { // http://codeforces.com/contest/785/submission/25535933 (Narenji58) int[] aa, bb; int n, k; int search(int i, int j, int a) { int lower = i - 1, upper = j; while (upper - lower > 1) { int m = (lower + upper) / 2; if (bb[m] <= a) lower = m; ...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
806c0ed375dd8eabcc1a1f66d672fd54
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
import java.io.*; public class CF785E { static int[] aa; static int[][] tt; static int n, k, m; static void update(int i, int j_, int a) { while (i < m) { int j = j_; while (j < n) { tt[i][j] += a; j |= j + 1; } i |= i + 1; } } static int query(int i, int j_) { int sum = 0; while (i >...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
01bcfeec016ceef129fc4799236df508
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
import java.util.*; public class E{ final int MAXN = (int)2e5 + 10, SQ = 333; int[] a = new int[MAXN], b = new int[MAXN]; int n; int bs(int l, int r, int x){ int lo = 0, hi = r-l+1; while (hi-lo>1){ int mid = hi+lo>>1; if (b[l+mid - 1] < x) lo = mid; else hi = mid; } return lo; } int g...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
dc029947a4d950ebfc0b0e5dfc18f93d
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
/* Used 2d-BIT and square-root decomsition. 1st devide the array into sqrt(n) blocks. now we have to sqrt(n) blocks. Each block has a BIT. to fasten the update operation in all the blocks, used 2d-BIT. */ import java.util.*; import java.io.*; public class CF785E_5{ public static int sqrt, maxn, bit[][], arr[]; ...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
7cdf5e9c0f76b488a39aaafec2fa026d
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
import java.util.*; import java.io.*; public class CF785E_5{ public static int sqrt, maxn, bit[][], arr[]; public static void main(String[] args)throws Exception { InputReader in = new InputReader(System.in); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); int n = in.nextInt(), q...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
5c12a9945da372a52047411b5a3eb28c
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
//package round404; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; public class E2 { InputStream is; PrintWriter out; String INPUT = ""; void so...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
837912a44b9de2c4bf0fb99907fbc79b
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
//package round404; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; public class E { InputStream is; PrintWriter out; String INPUT = ""; void sol...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
7f824d0e29d6de1dff8f7852abebebfb
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
//package round404; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class E3 { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(); in...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
f68188c04539a3964e1a8b5759fa5273
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
import java.io.*; import java.util.*; import java.math.*; public final class anton_and_perm { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc=new FastScanner(br); static PrintWriter out=new PrintWriter(System.out); static Random rnd=new Random(); static i...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
a088358a6dcc50d2e98d09aaca2af997
train_002.jsonl
1489590300
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.One day Anton got a new permutation and started to play with it. He does the following operation q times: he t...
512 megabytes
/* * Author Ayub Subhaniya * Institute DA-IICT */ import java.io.*; import java.math.*; import java.util.*; public class JuneLong{ InputStream in; PrintWriter out; int MAX; int N; void solve() { int n=ni(); int m=ni(); int a[]=new int[n]; for (int i=0;i<n;i++) a[i]=i+1; MAX=n; N=500; //...
Java
["5 4\n4 5\n2 4\n2 5\n2 2", "2 1\n2 1", "6 7\n1 4\n3 5\n2 3\n3 3\n3 6\n2 1\n5 1"]
4 seconds
["1\n4\n3\n3", "1", "5\n6\n7\n7\n10\n11\n8"]
NoteConsider the first sample.After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).After the third Anton's operation th...
Java 8
standard input
[ "data structures", "brute force" ]
ed9375dfd4749173472c0c18814c2855
The first line of the input contains two integers n and q (1 ≀ n ≀ 200 000, 1 ≀ q ≀ 50 000)Β β€” the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers li and ri (1 ≀ li, ri ≀ n)Β β€” the indices of elements that Anton swaps during the i-th...
2,200
Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.
standard output
PASSED
d6dbe9c1f06d6c99d69c8e0a3cbe049a
train_002.jsonl
1384156800
Let's assume that we are given an n × m table filled by integers. We'll mark a cell in the i-th row and j-th column as (i, j). Thus, (1, 1) is the upper left cell of the table and (n, m) is the lower right cell. We'll assume that a circle of radius r with the center in cell (i0, j0) is a set of such cells (i, j) that ....
256 megabytes
//363E import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class TwoCircles { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ...
Java
["2 2 0\n1 2\n2 4", "5 6 1\n4 2 1 3 2 6\n2 3 2 4 7 2\n5 2 2 1 1 3\n1 4 3 3 6 4\n5 1 4 2 3 2", "3 3 1\n1 2 3\n4 5 6\n7 8 9"]
4 seconds
["6 2", "34 3", "0 0"]
null
Java 8
standard input
[ "data structures", "implementation", "brute force" ]
a1ef0079119e18de424a81b05b68bb4c
The first line contains three integers n, m and r (2 ≀ n, m ≀ 500, r β‰₯ 0). Each of the following n lines contains m integers from 1 to 1000 each β€” the elements of the table. The rows of the table are listed from top to bottom at the elements in the rows are listed from left to right. It is guaranteed that there is at l...
2,500
Print two integers β€” the maximum sum of numbers in the cells that are located into two non-intersecting circles and the number of pairs of non-intersecting circles with the maximum sum. If there isn't a single pair of non-intersecting circles, print 0 0.
standard output
PASSED
d1d855522be19e51af6ecbe94ef9bc07
train_002.jsonl
1572087900
The only difference between easy and hard versions is constraints.The BerTV channel every day broadcasts one episode of one of the $$$k$$$ TV shows. You know the schedule for the next $$$n$$$ days: a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le k$$$), where $$$a_i$$$ is the show, the episode of whi...
256 megabytes
import java.util.*; import java.io.*; public class Main { static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenize...
Java
["4\n5 2 2\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 2 1 1 1\n4 10 4\n10 8 6 4\n16 9 8\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3"]
2 seconds
["2\n1\n4\n5"]
NoteIn the first test case to have an opportunity to watch shows for two consecutive days, you need to buy a subscription on show $$$1$$$ and on show $$$2$$$. So the answer is two.In the second test case, you can buy a subscription to any show because for each show you can find a segment of three consecutive days, cons...
Java 11
standard input
[ "two pointers", "implementation" ]
56da4ec7cd849c4330d188d8c9bd6094
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) β€” the number of test cases in the input. Then $$$t$$$ test case descriptions follow. The first line of each test case contains three integers $$$n, k$$$ and $$$d$$$ ($$$1 \le n \le 100$$$, $$$1 \le k \le 100$$$, $$$1 \le d \le n$$$). The second line con...
1,300
Print $$$t$$$ integers β€” the answers to the test cases in the input in the order they follow. The answer to a test case is the minimum number of TV shows for which you need to purchase a subscription so that you can watch episodes of the purchased TV shows on BerTV for $$$d$$$ consecutive days. Please note that it is p...
standard output
PASSED
18a63d9a1de09337f9f01afca9562748
train_002.jsonl
1572087900
The only difference between easy and hard versions is constraints.The BerTV channel every day broadcasts one episode of one of the $$$k$$$ TV shows. You know the schedule for the next $$$n$$$ days: a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le k$$$), where $$$a_i$$$ is the show, the episode of whi...
256 megabytes
import java.io.PrintWriter; import java.util.HashMap; import java.util.Scanner; public class TVSubscriptionsB_Hard extends PrintWriter { //this trick improves performances TVSubscriptionsB_Hard() { super(System.out); } public static void main(String[] $) { TVSubscriptionsB_Hard o = n...
Java
["4\n5 2 2\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 2 1 1 1\n4 10 4\n10 8 6 4\n16 9 8\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3"]
2 seconds
["2\n1\n4\n5"]
NoteIn the first test case to have an opportunity to watch shows for two consecutive days, you need to buy a subscription on show $$$1$$$ and on show $$$2$$$. So the answer is two.In the second test case, you can buy a subscription to any show because for each show you can find a segment of three consecutive days, cons...
Java 11
standard input
[ "two pointers", "implementation" ]
56da4ec7cd849c4330d188d8c9bd6094
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) β€” the number of test cases in the input. Then $$$t$$$ test case descriptions follow. The first line of each test case contains three integers $$$n, k$$$ and $$$d$$$ ($$$1 \le n \le 100$$$, $$$1 \le k \le 100$$$, $$$1 \le d \le n$$$). The second line con...
1,300
Print $$$t$$$ integers β€” the answers to the test cases in the input in the order they follow. The answer to a test case is the minimum number of TV shows for which you need to purchase a subscription so that you can watch episodes of the purchased TV shows on BerTV for $$$d$$$ consecutive days. Please note that it is p...
standard output
PASSED
2d88521308e6fa9b42ecc00fb215b681
train_002.jsonl
1572087900
The only difference between easy and hard versions is constraints.The BerTV channel every day broadcasts one episode of one of the $$$k$$$ TV shows. You know the schedule for the next $$$n$$$ days: a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le k$$$), where $$$a_i$$$ is the show, the episode of whi...
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class Main{ public static void main(String []args){ Scanner in = new Scanner(System.in); int test; test = in.nextInt(); while(test-->0){ int n, k, d; n = in.nextInt(); k = in.nextInt(...
Java
["4\n5 2 2\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 2 1 1 1\n4 10 4\n10 8 6 4\n16 9 8\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3"]
2 seconds
["2\n1\n4\n5"]
NoteIn the first test case to have an opportunity to watch shows for two consecutive days, you need to buy a subscription on show $$$1$$$ and on show $$$2$$$. So the answer is two.In the second test case, you can buy a subscription to any show because for each show you can find a segment of three consecutive days, cons...
Java 11
standard input
[ "two pointers", "implementation" ]
56da4ec7cd849c4330d188d8c9bd6094
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) β€” the number of test cases in the input. Then $$$t$$$ test case descriptions follow. The first line of each test case contains three integers $$$n, k$$$ and $$$d$$$ ($$$1 \le n \le 100$$$, $$$1 \le k \le 100$$$, $$$1 \le d \le n$$$). The second line con...
1,300
Print $$$t$$$ integers β€” the answers to the test cases in the input in the order they follow. The answer to a test case is the minimum number of TV shows for which you need to purchase a subscription so that you can watch episodes of the purchased TV shows on BerTV for $$$d$$$ consecutive days. Please note that it is p...
standard output
PASSED
00465690e25225d1ed0ee824777e37ce
train_002.jsonl
1572087900
The only difference between easy and hard versions is constraints.The BerTV channel every day broadcasts one episode of one of the $$$k$$$ TV shows. You know the schedule for the next $$$n$$$ days: a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le k$$$), where $$$a_i$$$ is the show, the episode of whi...
256 megabytes
// practice with kaiboy import java.io.*; import java.util.*; public class CF1247B2 extends PrintWriter { CF1247B2() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1247B2 o = new CF1247B2(); o.main(); o.flush(); } static final int A = 1000000; void main() {...
Java
["4\n5 2 2\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 2 1 1 1\n4 10 4\n10 8 6 4\n16 9 8\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3"]
2 seconds
["2\n1\n4\n5"]
NoteIn the first test case to have an opportunity to watch shows for two consecutive days, you need to buy a subscription on show $$$1$$$ and on show $$$2$$$. So the answer is two.In the second test case, you can buy a subscription to any show because for each show you can find a segment of three consecutive days, cons...
Java 11
standard input
[ "two pointers", "implementation" ]
56da4ec7cd849c4330d188d8c9bd6094
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) β€” the number of test cases in the input. Then $$$t$$$ test case descriptions follow. The first line of each test case contains three integers $$$n, k$$$ and $$$d$$$ ($$$1 \le n \le 100$$$, $$$1 \le k \le 100$$$, $$$1 \le d \le n$$$). The second line con...
1,300
Print $$$t$$$ integers β€” the answers to the test cases in the input in the order they follow. The answer to a test case is the minimum number of TV shows for which you need to purchase a subscription so that you can watch episodes of the purchased TV shows on BerTV for $$$d$$$ consecutive days. Please note that it is p...
standard output
PASSED
089bace00f63154b6cdf745bd4d56e06
train_002.jsonl
1572087900
The only difference between easy and hard versions is constraints.The BerTV channel every day broadcasts one episode of one of the $$$k$$$ TV shows. You know the schedule for the next $$$n$$$ days: a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le k$$$), where $$$a_i$$$ is the show, the episode of whi...
256 megabytes
import java.util.*; import java.math.*; public class cf { final static int N = (int) (2e5+10); static int t,n,k,d; static Map<Integer,Integer> mp=new HashMap<Integer,Integer>(); static int a[]=new int[N]; public static void main(String[] args) { Scanner scan=new Scanner(System.in); t=scan.nextInt();; while(-...
Java
["4\n5 2 2\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 2 1 1 1\n4 10 4\n10 8 6 4\n16 9 8\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3"]
2 seconds
["2\n1\n4\n5"]
NoteIn the first test case to have an opportunity to watch shows for two consecutive days, you need to buy a subscription on show $$$1$$$ and on show $$$2$$$. So the answer is two.In the second test case, you can buy a subscription to any show because for each show you can find a segment of three consecutive days, cons...
Java 11
standard input
[ "two pointers", "implementation" ]
56da4ec7cd849c4330d188d8c9bd6094
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) β€” the number of test cases in the input. Then $$$t$$$ test case descriptions follow. The first line of each test case contains three integers $$$n, k$$$ and $$$d$$$ ($$$1 \le n \le 100$$$, $$$1 \le k \le 100$$$, $$$1 \le d \le n$$$). The second line con...
1,300
Print $$$t$$$ integers β€” the answers to the test cases in the input in the order they follow. The answer to a test case is the minimum number of TV shows for which you need to purchase a subscription so that you can watch episodes of the purchased TV shows on BerTV for $$$d$$$ consecutive days. Please note that it is p...
standard output
PASSED
c83b4880f88e40c99b70d348d58db9c3
train_002.jsonl
1572087900
The only difference between easy and hard versions is constraints.The BerTV channel every day broadcasts one episode of one of the $$$k$$$ TV shows. You know the schedule for the next $$$n$$$ days: a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le k$$$), where $$$a_i$$$ is the show, the episode of whi...
256 megabytes
import java.io.*; import java.util.*; public class B { public void solve() throws IOException { int t = nextInt(); while (t-- > 0) { int n = nextInt(), k = nextInt(), d = nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = next...
Java
["4\n5 2 2\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 2 1 1 1\n4 10 4\n10 8 6 4\n16 9 8\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3"]
2 seconds
["2\n1\n4\n5"]
NoteIn the first test case to have an opportunity to watch shows for two consecutive days, you need to buy a subscription on show $$$1$$$ and on show $$$2$$$. So the answer is two.In the second test case, you can buy a subscription to any show because for each show you can find a segment of three consecutive days, cons...
Java 11
standard input
[ "two pointers", "implementation" ]
56da4ec7cd849c4330d188d8c9bd6094
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) β€” the number of test cases in the input. Then $$$t$$$ test case descriptions follow. The first line of each test case contains three integers $$$n, k$$$ and $$$d$$$ ($$$1 \le n \le 100$$$, $$$1 \le k \le 100$$$, $$$1 \le d \le n$$$). The second line con...
1,300
Print $$$t$$$ integers β€” the answers to the test cases in the input in the order they follow. The answer to a test case is the minimum number of TV shows for which you need to purchase a subscription so that you can watch episodes of the purchased TV shows on BerTV for $$$d$$$ consecutive days. Please note that it is p...
standard output
PASSED
488004bffc26849faa956ce76d3a1789
train_002.jsonl
1572087900
The only difference between easy and hard versions is constraints.The BerTV channel every day broadcasts one episode of one of the $$$k$$$ TV shows. You know the schedule for the next $$$n$$$ days: a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le k$$$), where $$$a_i$$$ is the show, the episode of whi...
256 megabytes
import java.io.*; import java.util.*; public class A { public static void main(String[] args) throws Throwable { sc = new Scanner(); pw = new PrintWriter(System.out); int mx = (int) 1e6 + 1; int[] cnt = new int[mx]; int t = sc.nextInt(); while (t-- > 0) { ...
Java
["4\n5 2 2\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 2 1 1 1\n4 10 4\n10 8 6 4\n16 9 8\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3"]
2 seconds
["2\n1\n4\n5"]
NoteIn the first test case to have an opportunity to watch shows for two consecutive days, you need to buy a subscription on show $$$1$$$ and on show $$$2$$$. So the answer is two.In the second test case, you can buy a subscription to any show because for each show you can find a segment of three consecutive days, cons...
Java 11
standard input
[ "two pointers", "implementation" ]
56da4ec7cd849c4330d188d8c9bd6094
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) β€” the number of test cases in the input. Then $$$t$$$ test case descriptions follow. The first line of each test case contains three integers $$$n, k$$$ and $$$d$$$ ($$$1 \le n \le 100$$$, $$$1 \le k \le 100$$$, $$$1 \le d \le n$$$). The second line con...
1,300
Print $$$t$$$ integers β€” the answers to the test cases in the input in the order they follow. The answer to a test case is the minimum number of TV shows for which you need to purchase a subscription so that you can watch episodes of the purchased TV shows on BerTV for $$$d$$$ consecutive days. Please note that it is p...
standard output
PASSED
f6e45946989ef989027be8eabe13a584
train_002.jsonl
1572087900
The only difference between easy and hard versions is constraints.The BerTV channel every day broadcasts one episode of one of the $$$k$$$ TV shows. You know the schedule for the next $$$n$$$ days: a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le k$$$), where $$$a_i$$$ is the show, the episode of whi...
256 megabytes
import java.io.*; import java.util.*; public class Main{ public static void main(String[] args) throws Exception{ MScanner sc=new MScanner(System.in); PrintWriter pw=new PrintWriter(System.out); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(),k=sc.nextInt(),d=sc.nextInt(); int[]in=sc.takearr(n...
Java
["4\n5 2 2\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 2 1 1 1\n4 10 4\n10 8 6 4\n16 9 8\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3"]
2 seconds
["2\n1\n4\n5"]
NoteIn the first test case to have an opportunity to watch shows for two consecutive days, you need to buy a subscription on show $$$1$$$ and on show $$$2$$$. So the answer is two.In the second test case, you can buy a subscription to any show because for each show you can find a segment of three consecutive days, cons...
Java 11
standard input
[ "two pointers", "implementation" ]
56da4ec7cd849c4330d188d8c9bd6094
The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) β€” the number of test cases in the input. Then $$$t$$$ test case descriptions follow. The first line of each test case contains three integers $$$n, k$$$ and $$$d$$$ ($$$1 \le n \le 100$$$, $$$1 \le k \le 100$$$, $$$1 \le d \le n$$$). The second line con...
1,300
Print $$$t$$$ integers β€” the answers to the test cases in the input in the order they follow. The answer to a test case is the minimum number of TV shows for which you need to purchase a subscription so that you can watch episodes of the purchased TV shows on BerTV for $$$d$$$ consecutive days. Please note that it is p...
standard output
PASSED
187720767162cb5eddc8bfa3fb9cb52f
train_002.jsonl
1588775700
Logical quantifiers are very useful tools for expressing claims about a set. For this problem, let's focus on the set of real numbers specifically. The set of real numbers includes zero and negatives. There are two kinds of quantifiers: universal ($$$\forall$$$) and existential ($$$\exists$$$). You can read more about ...
256 megabytes
/** * @author derrick20 */ import java.io.*; import java.util.*; public class QuantifierQuestion { public static void main(String[] args) throws Exception { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int N = sc.nextInt(); int M = sc.nextInt...
Java
["2 1\n1 2", "4 3\n1 2\n2 3\n3 1", "3 2\n1 3\n2 3"]
1 second
["1\nAE", "-1", "2\nAAE"]
NoteFor the first test, the statement $$$\forall x_1, \exists x_2, x_1&lt;x_2$$$ is true. Answers of "EA" and "AA" give false statements. The answer "EE" gives a true statement, but the number of universal quantifiers in this string is less than in our answer.For the second test, we can show that no assignment of quant...
Java 11
standard input
[ "dp", "dfs and similar", "graphs" ]
94e58f3f7aa4d860b95d34c7c9f89058
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2\le n\le 2\cdot 10^5$$$; $$$1\le m\le 2\cdot 10^5$$$)Β β€” the number of variables and the number of inequalities in the formula, respectively. The next $$$m$$$ lines describe the formula. The $$$i$$$-th of these lines contains two integers $$$j_i$$$,$$$k_i$$$ ...
2,600
If there is no assignment of quantifiers for which the statement is true, output a single integer $$$-1$$$. Otherwise, on the first line output an integer, the maximum possible number of universal quantifiers. On the next line, output a string of length $$$n$$$, where the $$$i$$$-th character is "A" if $$$Q_i$$$ should...
standard output
PASSED
12140b2d3a23892128c58cb6f212597f
train_002.jsonl
1588775700
Logical quantifiers are very useful tools for expressing claims about a set. For this problem, let's focus on the set of real numbers specifically. The set of real numbers includes zero and negatives. There are two kinds of quantifiers: universal ($$$\forall$$$) and existential ($$$\exists$$$). You can read more about ...
256 megabytes
// upsolve with kaiboy import java.io.*; import java.util.*; public class CF1345E extends PrintWriter { CF1345E() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1345E o = new CF1345E(); o.main(); o.flush(); } int[] oo, oj; int __ = 1; int link(int o, ...
Java
["2 1\n1 2", "4 3\n1 2\n2 3\n3 1", "3 2\n1 3\n2 3"]
1 second
["1\nAE", "-1", "2\nAAE"]
NoteFor the first test, the statement $$$\forall x_1, \exists x_2, x_1&lt;x_2$$$ is true. Answers of "EA" and "AA" give false statements. The answer "EE" gives a true statement, but the number of universal quantifiers in this string is less than in our answer.For the second test, we can show that no assignment of quant...
Java 11
standard input
[ "dp", "dfs and similar", "graphs" ]
94e58f3f7aa4d860b95d34c7c9f89058
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2\le n\le 2\cdot 10^5$$$; $$$1\le m\le 2\cdot 10^5$$$)Β β€” the number of variables and the number of inequalities in the formula, respectively. The next $$$m$$$ lines describe the formula. The $$$i$$$-th of these lines contains two integers $$$j_i$$$,$$$k_i$$$ ...
2,600
If there is no assignment of quantifiers for which the statement is true, output a single integer $$$-1$$$. Otherwise, on the first line output an integer, the maximum possible number of universal quantifiers. On the next line, output a string of length $$$n$$$, where the $$$i$$$-th character is "A" if $$$Q_i$$$ should...
standard output
PASSED
537e5c561a331e4a34715b791bd35427
train_002.jsonl
1588775700
Logical quantifiers are very useful tools for expressing claims about a set. For this problem, let's focus on the set of real numbers specifically. The set of real numbers includes zero and negatives. There are two kinds of quantifiers: universal ($$$\forall$$$) and existential ($$$\exists$$$). You can read more about ...
256 megabytes
import java.io.*; import java.util.*; public class Main { private boolean hasCir(List<List<Integer>> g) { int n = g.size(); int[] d = new int[n]; for (List<Integer> child : g) { for (int v : child) { ++d[v]; } } Queue<Integer> q = n...
Java
["2 1\n1 2", "4 3\n1 2\n2 3\n3 1", "3 2\n1 3\n2 3"]
1 second
["1\nAE", "-1", "2\nAAE"]
NoteFor the first test, the statement $$$\forall x_1, \exists x_2, x_1&lt;x_2$$$ is true. Answers of "EA" and "AA" give false statements. The answer "EE" gives a true statement, but the number of universal quantifiers in this string is less than in our answer.For the second test, we can show that no assignment of quant...
Java 11
standard input
[ "dp", "dfs and similar", "graphs" ]
94e58f3f7aa4d860b95d34c7c9f89058
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2\le n\le 2\cdot 10^5$$$; $$$1\le m\le 2\cdot 10^5$$$)Β β€” the number of variables and the number of inequalities in the formula, respectively. The next $$$m$$$ lines describe the formula. The $$$i$$$-th of these lines contains two integers $$$j_i$$$,$$$k_i$$$ ...
2,600
If there is no assignment of quantifiers for which the statement is true, output a single integer $$$-1$$$. Otherwise, on the first line output an integer, the maximum possible number of universal quantifiers. On the next line, output a string of length $$$n$$$, where the $$$i$$$-th character is "A" if $$$Q_i$$$ should...
standard output
PASSED
44b44cd22ab5dd3f00f5714f47c8dcab
train_002.jsonl
1492266900
One day Masha came home and noticed n mice in the corridor of her flat. Of course, she shouted loudly, so scared mice started to run to the holes in the corridor.The corridor can be represeted as a numeric axis with n mice and m holes on it. ith mouse is at the coordinate xi, and jth hole β€” at coordinate pj. jth hole h...
256 megabytes
import java.io.*; import java.lang.*; import java.util.*; import java.util.concurrent.*; import java.util.function.*; public class F { public static void main(String[] args) { int n = in.nextInt(); int m = in.nextInt(); long[] x = in.nextLongs(n, true); long[][] pc = new long[m + 1][2]; /* for (i...
Java
["4 5\n6 2 8 9\n3 6\n2 1\n3 6\n4 7\n4 7", "7 2\n10 20 30 40 50 45 35\n-1000000000 10\n1000000000 1"]
1.5 seconds
["11", "7000000130"]
null
Java 8
standard input
[ "dp", "sortings", "greedy", "data structures" ]
d9adb80515689c6939f8e010005f7208
The first line contains two integer numbers n, m (1 ≀ n, m ≀ 5000) β€” the number of mice and the number of holes, respectively. The second line contains n integers x1, x2, ..., xn ( - 109 ≀ xi ≀ 109), where xi is the coordinate of ith mouse. Next m lines contain pairs of integer numbers pj, cj ( - 109 ≀ pj ≀ 109, 1 ≀ cj...
2,600
Print one integer number β€” the minimum sum of distances. If there is no solution, print -1 instead.
standard output
PASSED
9135d93094375b267ad32ce6f616f4d6
train_002.jsonl
1492266900
One day Masha came home and noticed n mice in the corridor of her flat. Of course, she shouted loudly, so scared mice started to run to the holes in the corridor.The corridor can be represeted as a numeric axis with n mice and m holes on it. ith mouse is at the coordinate xi, and jth hole β€” at coordinate pj. jth hole h...
256 megabytes
//package educational.round19; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class FY { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n =...
Java
["4 5\n6 2 8 9\n3 6\n2 1\n3 6\n4 7\n4 7", "7 2\n10 20 30 40 50 45 35\n-1000000000 10\n1000000000 1"]
1.5 seconds
["11", "7000000130"]
null
Java 8
standard input
[ "dp", "sortings", "greedy", "data structures" ]
d9adb80515689c6939f8e010005f7208
The first line contains two integer numbers n, m (1 ≀ n, m ≀ 5000) β€” the number of mice and the number of holes, respectively. The second line contains n integers x1, x2, ..., xn ( - 109 ≀ xi ≀ 109), where xi is the coordinate of ith mouse. Next m lines contain pairs of integer numbers pj, cj ( - 109 ≀ pj ≀ 109, 1 ≀ cj...
2,600
Print one integer number β€” the minimum sum of distances. If there is no solution, print -1 instead.
standard output
PASSED
d0acd0b2be5b2969184448192dc079eb
train_002.jsonl
1492266900
One day Masha came home and noticed n mice in the corridor of her flat. Of course, she shouted loudly, so scared mice started to run to the holes in the corridor.The corridor can be represeted as a numeric axis with n mice and m holes on it. ith mouse is at the coordinate xi, and jth hole β€” at coordinate pj. jth hole h...
256 megabytes
//package educational.round19; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; // 1621 public class FX { InputStream is; PrintWriter out; String INPUT = ""; void solve() { ...
Java
["4 5\n6 2 8 9\n3 6\n2 1\n3 6\n4 7\n4 7", "7 2\n10 20 30 40 50 45 35\n-1000000000 10\n1000000000 1"]
1.5 seconds
["11", "7000000130"]
null
Java 8
standard input
[ "dp", "sortings", "greedy", "data structures" ]
d9adb80515689c6939f8e010005f7208
The first line contains two integer numbers n, m (1 ≀ n, m ≀ 5000) β€” the number of mice and the number of holes, respectively. The second line contains n integers x1, x2, ..., xn ( - 109 ≀ xi ≀ 109), where xi is the coordinate of ith mouse. Next m lines contain pairs of integer numbers pj, cj ( - 109 ≀ pj ≀ 109, 1 ≀ cj...
2,600
Print one integer number β€” the minimum sum of distances. If there is no solution, print -1 instead.
standard output
PASSED
0e68286f35ef8c8a4ac247a7e6a47ab4
train_002.jsonl
1492266900
One day Masha came home and noticed n mice in the corridor of her flat. Of course, she shouted loudly, so scared mice started to run to the holes in the corridor.The corridor can be represeted as a numeric axis with n mice and m holes on it. ith mouse is at the coordinate xi, and jth hole β€” at coordinate pj. jth hole h...
256 megabytes
//package educational.round19; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class FY { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n =...
Java
["4 5\n6 2 8 9\n3 6\n2 1\n3 6\n4 7\n4 7", "7 2\n10 20 30 40 50 45 35\n-1000000000 10\n1000000000 1"]
1.5 seconds
["11", "7000000130"]
null
Java 8
standard input
[ "dp", "sortings", "greedy", "data structures" ]
d9adb80515689c6939f8e010005f7208
The first line contains two integer numbers n, m (1 ≀ n, m ≀ 5000) β€” the number of mice and the number of holes, respectively. The second line contains n integers x1, x2, ..., xn ( - 109 ≀ xi ≀ 109), where xi is the coordinate of ith mouse. Next m lines contain pairs of integer numbers pj, cj ( - 109 ≀ pj ≀ 109, 1 ≀ cj...
2,600
Print one integer number β€” the minimum sum of distances. If there is no solution, print -1 instead.
standard output
PASSED
399b0e8f074d8a352611f3dc50afc3d2
train_002.jsonl
1414170000
You play the game with your friend. The description of this game is listed below. Your friend creates n distinct strings of the same length m and tells you all the strings. Then he randomly chooses one of them. He chooses strings equiprobably, i.e. the probability of choosing each of the n strings equals . You want to ...
256 megabytes
//import java.awt.Dimension; import java.awt.Point; import java.io.*; import static java.lang.Character.*; import static java.lang.Math.*; import java.math.BigDecimal; import java.math.BigInteger; import static java.math.BigInteger.*; import java.util.*; import static java.util.A...
Java
["2\naab\naac", "3\naaA\naBa\nCaa", "3\naca\nvac\nwqq"]
1 second
["2.000000000000000", "1.666666666666667", "1.000000000000000"]
NoteIn the first sample the strings only differ in the character in the third position. So only the following situations are possible: you guess the string in one question. The event's probability is ; you guess the string in two questions. The event's probability is Β· = (as in this case the first question should...
Java 7
standard input
[ "dp", "bitmasks", "probabilities" ]
a95d9aef6a64c30e46330dcc8e6d4a67
The first line contains a single integer n (1 ≀ n ≀ 50)Β β€” the number of strings your friend came up with. The next n lines contain the strings that your friend has created. It is guaranteed that all the strings are distinct and only consist of large and small English letters. Besides, the lengths of all strings are the...
2,600
Print the single number β€” the expected value. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 9.
standard output
PASSED
0fa97a4bf99d4c7e6e26701217f53ca7
train_002.jsonl
1414170000
You play the game with your friend. The description of this game is listed below. Your friend creates n distinct strings of the same length m and tells you all the strings. Then he randomly chooses one of them. He chooses strings equiprobably, i.e. the probability of choosing each of the n strings equals . You want to ...
256 megabytes
//import java.awt.Dimension; import java.awt.Point; import java.io.*; import static java.lang.Character.*; import static java.lang.Math.*; import java.math.BigDecimal; import java.math.BigInteger; import static java.math.BigInteger.*; import java.util.*; import static java.util.A...
Java
["2\naab\naac", "3\naaA\naBa\nCaa", "3\naca\nvac\nwqq"]
1 second
["2.000000000000000", "1.666666666666667", "1.000000000000000"]
NoteIn the first sample the strings only differ in the character in the third position. So only the following situations are possible: you guess the string in one question. The event's probability is ; you guess the string in two questions. The event's probability is Β· = (as in this case the first question should...
Java 7
standard input
[ "dp", "bitmasks", "probabilities" ]
a95d9aef6a64c30e46330dcc8e6d4a67
The first line contains a single integer n (1 ≀ n ≀ 50)Β β€” the number of strings your friend came up with. The next n lines contain the strings that your friend has created. It is guaranteed that all the strings are distinct and only consist of large and small English letters. Besides, the lengths of all strings are the...
2,600
Print the single number β€” the expected value. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 9.
standard output
PASSED
e2788c8c2fd1f1130dd549039413301c
train_002.jsonl
1414170000
You play the game with your friend. The description of this game is listed below. Your friend creates n distinct strings of the same length m and tells you all the strings. Then he randomly chooses one of them. He chooses strings equiprobably, i.e. the probability of choosing each of the n strings equals . You want to ...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String[] word = new String[n]; for (int i = 0; i < n; i++) { word[i] = sc.next(); } int k = word[0].length(); long[] bad = new long[1 << k]; for (int i = 0...
Java
["2\naab\naac", "3\naaA\naBa\nCaa", "3\naca\nvac\nwqq"]
1 second
["2.000000000000000", "1.666666666666667", "1.000000000000000"]
NoteIn the first sample the strings only differ in the character in the third position. So only the following situations are possible: you guess the string in one question. The event's probability is ; you guess the string in two questions. The event's probability is Β· = (as in this case the first question should...
Java 7
standard input
[ "dp", "bitmasks", "probabilities" ]
a95d9aef6a64c30e46330dcc8e6d4a67
The first line contains a single integer n (1 ≀ n ≀ 50)Β β€” the number of strings your friend came up with. The next n lines contain the strings that your friend has created. It is guaranteed that all the strings are distinct and only consist of large and small English letters. Besides, the lengths of all strings are the...
2,600
Print the single number β€” the expected value. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 9.
standard output
PASSED
ba3c058b2254a21d207d12d631e60479
train_002.jsonl
1414170000
You play the game with your friend. The description of this game is listed below. Your friend creates n distinct strings of the same length m and tells you all the strings. Then he randomly chooses one of them. He chooses strings equiprobably, i.e. the probability of choosing each of the n strings equals . You want to ...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String[] word = new String[n]; for (int i = 0; i < n; i++) { word[i] = sc.next(); } int k = word[0].length(); long[] bad = new long[1 << k]; for (int i = 0...
Java
["2\naab\naac", "3\naaA\naBa\nCaa", "3\naca\nvac\nwqq"]
1 second
["2.000000000000000", "1.666666666666667", "1.000000000000000"]
NoteIn the first sample the strings only differ in the character in the third position. So only the following situations are possible: you guess the string in one question. The event's probability is ; you guess the string in two questions. The event's probability is Β· = (as in this case the first question should...
Java 7
standard input
[ "dp", "bitmasks", "probabilities" ]
a95d9aef6a64c30e46330dcc8e6d4a67
The first line contains a single integer n (1 ≀ n ≀ 50)Β β€” the number of strings your friend came up with. The next n lines contain the strings that your friend has created. It is guaranteed that all the strings are distinct and only consist of large and small English letters. Besides, the lengths of all strings are the...
2,600
Print the single number β€” the expected value. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 9.
standard output
PASSED
7eb210190973aab664a1544590e55db6
train_002.jsonl
1414170000
You play the game with your friend. The description of this game is listed below. Your friend creates n distinct strings of the same length m and tells you all the strings. Then he randomly chooses one of them. He chooses strings equiprobably, i.e. the probability of choosing each of the n strings equals . You want to ...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String[] word = new String[n]; for (int i = 0; i < n; i++) { word[i] = sc.next(); } int k = word[0].length(); long[] bad = new long[1 << k]; for (int i = 0...
Java
["2\naab\naac", "3\naaA\naBa\nCaa", "3\naca\nvac\nwqq"]
1 second
["2.000000000000000", "1.666666666666667", "1.000000000000000"]
NoteIn the first sample the strings only differ in the character in the third position. So only the following situations are possible: you guess the string in one question. The event's probability is ; you guess the string in two questions. The event's probability is Β· = (as in this case the first question should...
Java 7
standard input
[ "dp", "bitmasks", "probabilities" ]
a95d9aef6a64c30e46330dcc8e6d4a67
The first line contains a single integer n (1 ≀ n ≀ 50)Β β€” the number of strings your friend came up with. The next n lines contain the strings that your friend has created. It is guaranteed that all the strings are distinct and only consist of large and small English letters. Besides, the lengths of all strings are the...
2,600
Print the single number β€” the expected value. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 9.
standard output
PASSED
f670649adddcfa3237941b77d3d198c6
train_002.jsonl
1414170000
You play the game with your friend. The description of this game is listed below. Your friend creates n distinct strings of the same length m and tells you all the strings. Then he randomly chooses one of them. He chooses strings equiprobably, i.e. the probability of choosing each of the n strings equals . You want to ...
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String[] word = new String[n]; for (int i = 0; i < n; i++) { word[i] = sc.next(); } int k = word[0].length(); long[] bad = new long[1 << k]; for (int i = 0...
Java
["2\naab\naac", "3\naaA\naBa\nCaa", "3\naca\nvac\nwqq"]
1 second
["2.000000000000000", "1.666666666666667", "1.000000000000000"]
NoteIn the first sample the strings only differ in the character in the third position. So only the following situations are possible: you guess the string in one question. The event's probability is ; you guess the string in two questions. The event's probability is Β· = (as in this case the first question should...
Java 7
standard input
[ "dp", "bitmasks", "probabilities" ]
a95d9aef6a64c30e46330dcc8e6d4a67
The first line contains a single integer n (1 ≀ n ≀ 50)Β β€” the number of strings your friend came up with. The next n lines contain the strings that your friend has created. It is guaranteed that all the strings are distinct and only consist of large and small English letters. Besides, the lengths of all strings are the...
2,600
Print the single number β€” the expected value. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 9.
standard output
PASSED
73dcc3f5ed2f104b1c7c5aa9a2c1078c
train_002.jsonl
1414170000
You play the game with your friend. The description of this game is listed below. Your friend creates n distinct strings of the same length m and tells you all the strings. Then he randomly chooses one of them. He chooses strings equiprobably, i.e. the probability of choosing each of the n strings equals . You want to ...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public cla...
Java
["2\naab\naac", "3\naaA\naBa\nCaa", "3\naca\nvac\nwqq"]
1 second
["2.000000000000000", "1.666666666666667", "1.000000000000000"]
NoteIn the first sample the strings only differ in the character in the third position. So only the following situations are possible: you guess the string in one question. The event's probability is ; you guess the string in two questions. The event's probability is Β· = (as in this case the first question should...
Java 7
standard input
[ "dp", "bitmasks", "probabilities" ]
a95d9aef6a64c30e46330dcc8e6d4a67
The first line contains a single integer n (1 ≀ n ≀ 50)Β β€” the number of strings your friend came up with. The next n lines contain the strings that your friend has created. It is guaranteed that all the strings are distinct and only consist of large and small English letters. Besides, the lengths of all strings are the...
2,600
Print the single number β€” the expected value. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 9.
standard output
PASSED
34269ab6f33176a8331f0951fa5c392c
train_002.jsonl
1414170000
You play the game with your friend. The description of this game is listed below. Your friend creates n distinct strings of the same length m and tells you all the strings. Then he randomly chooses one of them. He chooses strings equiprobably, i.e. the probability of choosing each of the n strings equals . You want to ...
256 megabytes
//package round275; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class C3 { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(); ch...
Java
["2\naab\naac", "3\naaA\naBa\nCaa", "3\naca\nvac\nwqq"]
1 second
["2.000000000000000", "1.666666666666667", "1.000000000000000"]
NoteIn the first sample the strings only differ in the character in the third position. So only the following situations are possible: you guess the string in one question. The event's probability is ; you guess the string in two questions. The event's probability is Β· = (as in this case the first question should...
Java 7
standard input
[ "dp", "bitmasks", "probabilities" ]
a95d9aef6a64c30e46330dcc8e6d4a67
The first line contains a single integer n (1 ≀ n ≀ 50)Β β€” the number of strings your friend came up with. The next n lines contain the strings that your friend has created. It is guaranteed that all the strings are distinct and only consist of large and small English letters. Besides, the lengths of all strings are the...
2,600
Print the single number β€” the expected value. Your answer will be considered correct if its absolute or relative error doesn't exceed 10 - 9.
standard output
PASSED
dc928252b4020a07f201e39ea2883c99
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
f873da3b48c7f1d3df1f1c8a82d1fbfc
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
17f7548dcd71a5c23fbfad17e052e9aa
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.*; import java.util.*; public class B { static Set<Integer> g[]; static int[] vis; static ArrayList<Integer> list; static TreeSet<Integer> set; public static void main(String[] args)throws IOException { FastReader f=new FastReader(); StringBuffer sb = new StringBuffer(); int n=f.n...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
f6fdbad90136004213dc2bad7fcc3f1d
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.*; import java.util.*; public class Main { private static PrintWriter out; private static FastReader in; private static boolean[] used; private static ArrayList<Integer> component; private static class FastReader { public BufferedReader reader; public StringTokenizer...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
8630958cdeb5bc525e75caba04039a25
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; import java.util.Vector; public class B { private int[] id; private int count; public B(int N) { count = N; id = new int[N]; for (int i = 0; i < N; i++) id[i] = i; } public int count() { return count; ...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
9c8e7e64d6e8256c807299500ffc8b8f
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] p = new int[n]; for (int i = 0; i < p.length;...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
b01f5543547fe0aa8d18e1961a29c3ac
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.ArrayList; ...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
fa98504b3721299504b0aeed567a181c
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class NewYearPermutation { public static void main(String[] args) { FastScanner scan = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n = scan.nextInt(); ...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
d09954b77593a4d3397f7af1780e9d07
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void solution(BufferedReader reader, PrintWriter out) throws IOException { In in = new In(reader); int n = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = in.nextInt()...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
91d0897be49ad70daf2db3160919bc71
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.StringTokenizer; public class Main { stati...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
8c55dff4f7b2c9db49d816e77bcc5ea8
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class GB14B { static int[] a; static char[][] mat; static int n; public static void main (String[] args) throws java.lang.Exception { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.ou...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
df2f6f924d0d1b762e09276b9a981d62
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; import java.util.StringTokenizer; public class p022 { static boolean[][] G; static int[] a,b; static int n; public static void main(String args[]) throws Exception { StringTokenizer stok = new StringTokenizer...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
940533e30448461f7eaed7bb7f7c9b2d
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.TreeSet; import java.io.InputStream; ...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
fd5bf059e72c78cb7e5bcded2613c620
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws NumberFo...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
baf43bb27e7a982dd3578e8f0ecd50c6
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.InputMismatchException; import java.util.StringTokenizer; public class permutations{ public static void main(String[] args){ Task task = new Task(); FastOutput out = new FastOutput(); task.solve(new FastInput(), out); out.c...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
d570372522d51d1f80d0d47fede474cc
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.util.*; import java.io.*; public class A { public static void main(String ar[]) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(br.readLine()); String s1[]=br.readLine().split(" "); ...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
15b6cbbc0f8c0afaef9d1ebee33b723c
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arra...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
ee6501d7598d3092a05282d147812110
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.util.*; import java.util.Scanner; public class Position { static int[] color; static ArrayList<ArrayList> Link; // Link[colorindex] gives the vertices in that colored region static int N; static int[] arr; static int[][] A; static ArrayList<Integer> dfs(int i, int col){ //Col...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
e90f9c76032ddc827cde965b047ee81f
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B { static int[] arr; static boolean[][] pos; static int N; public static void sort() { for (int j = 0; j < N; ++j) { for (int k = 0; k < N; +...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
a3dd615a94134cacf71072ed3d19d34d
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Bye_2014 { public static void main(String[] args) throws IOException{ PrintWriter pw = new PrintWriter(System.out, true); BufferedR...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
341341f292f6f30e6dc04c237f37dcb7
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { static PrintWriter out=new PrintWriter(System.out);static FastScanner in = new FastScanner(System.in);static class FastScanner {BufferedReader br;StringTokenizer stok;FastScanner(InputStream is) {br = new BufferedReader(new InputStr...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
d37a92d442bc790a9240b82bfcabf592
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.util.Scanner; public class Main { static int n; static int[] arr; static int[][] a; static boolean[] visited; static int value, pos, aim; public static void main(String[] args) { Scanner cin = new Scanner(System.in); n = cin.nextInt(); arr = new int[n]; ...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
a7016f4c325501f25a27de616e3145eb
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.*; public class A_GENERAL { // for fast output printing : use printwriter or stringbuilder // remember to close pw using pw.close() stati...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
88e59ed20b35be3920910e6d31b59acf
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; /** * * @author Tu Van Ninh */ public class ACMTraining { Scanner sc; int n; int[] p,v; String[] perm; ArrayList<Integer>[] edge; ArrayList<Integer>[] dsu; /** * @param args the command line argume...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
3fe56b7671cc44f8c33409ae1beb83ce
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
//package denxx; import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] p = new int[n]; for (int i = 0; i < n; ++i) { p[i] = in.nextInt(); } String[] a = new Stri...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
eea6a364c2ba29c7c048c38c6663174d
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.util.*; import java.io.*; public class Codeforces { InputStream is; PrintWriter out; String INPUT = ""; //----------------------------------------------------------------------------------------------------// void solve() { int n=ni(); Dsu uf=new Dsu(n); i...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
e8969313b29ee2dd5364df362f4b5827
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.util.*; import java.io.*; public class Graph { ArrayList<Integer> adj[]; static int V; Graph(int v) { V=v; adj=new ArrayList[v]; for(int i=0;i<v;i++) adj[i] = new ArrayList<>(); } void addEdge(int u,int v) { adj[u].add(v); adj[v].ad...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
119df9b844d43ede6d019216700a2372
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.util.PriorityQueue; import java.util.AbstractQueue; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built usin...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
4f015be5a8ba2d3fd4d1720bcc0ce99e
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.util.Scanner; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; public class Java { static Scanner sc = new Scanner(System.in); static int n = sc.nextInt(); static int[] fix = new int[n]; static ArrayList<ArrayList<Integer>> V = new ArrayList<ArrayList<Integer>>(); ...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
5e291bad21d10b487ecfef1b8ee07793
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.*; import java.util.*; public class NeyYearPerm{ static int[] id; public static void main(String[]args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); StringTokeni...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
493b0bc54e56917804ef35552bbffbe9
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.StringTokenizer; public class Main { static BufferedReader reader; static StringTokenizer tokenize...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
4fbf07d078fb0392b63f26ed1984640f
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.InputMismatchException; import java.io.IOException; import java.io.FileInputStream; import java.util.ArrayList; import java.util.Map; import java.util.Map.Entry; im...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
17c903deab905cba0577ec7b5eeecdd9
train_002.jsonl
1419951600
User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≀ k ≀ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak &lt; bk all h...
256 megabytes
import java.util.Scanner; public class NewYearPermutation{ /* public static double[] merge( double[] a, double[] b ){ int index1; int index2; int index3; double[] res; res = new double[ a.length + b.length ]; index1 = 0; index2 = 0; index3 = 0; while( index1 < a.l...
Java
["7\n5 2 4 3 6 7 1\n0001001\n0000000\n0000010\n1000001\n0000000\n0010000\n1001000", "5\n4 2 1 5 3\n00100\n00011\n10010\n01101\n01010"]
2 seconds
["1 2 4 3 6 7 5", "1 2 3 4 5"]
NoteIn the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4). A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them does...
Java 8
standard input
[ "greedy", "graphs", "math", "dsu", "sortings", "dfs and similar" ]
a67ea891cd6084ceeaace8894cf18e60
The first line contains an integer n (1 ≀ n ≀ 300) β€” the size of the permutation p. The second line contains n space-separated integers p1, p2, ..., pn β€” the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation. Next n lines describe the matrix A. The i-th line co...
1,600
In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.
standard output
PASSED
8754bcfb7fb78e7f7aff7ff0a6e86ee4
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { public static void main(String[] args) throws IOException { BufferedReader cin=new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new Prin...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
6fc79ca6ed1c76894f25450099abb186
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.util.Scanner; public class B_Worms { static int [] list = new int[1000010]; public static void main(String[] args) { // TODO Auto-generated method stub Scanner x = new Scanner(System.in); int k = x.nextInt(),temp; for (int i = 0,t = 0; i < k; i++) { ...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
661ee7f7b82ba6a5cd949abd889650ca
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.util.Scanner; public class Main { private static Scanner sc; private static int[] data; public static void main(String[] args) { sc = new Scanner(System.in); int n = sc.nextInt(); data = new int[n]; int init = 0; for (int i = 0; i < n; i++) { init += sc.nextInt(); data[i] = init; ...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
24ea1b1507829dd41ec975dfcd538b8a
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.Scanner; public class Main { static int[] pt = new int[100005]; static StreamTokenizer in = new StreamTokenizer...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
2f40c6239ffb98a2427afee1e28980da
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.io.*; import java.util.*; public class problem474B{ public static void main(String[]args)throws IOException{ BufferedReader x = new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(x.readLine()); int[]piles=new int[n]; StringTokenizer st=new StringTokenizer(x.readLine()); ...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
eeb9a668e664336090076ec15752ef4d
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputS...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
c5c9db9358274b2a0e1ead9720f2eb08
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class CF474B { final static int N=100005; static int a[]=new int[N]; public static void main(String args[]) { InputReader in=new InputReader(System.in); PrintWriter out=new PrintWriter(System.out); int n=in.nextInt(); ...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
027bcbf9e22ffe1c5b2e627ef337d00d
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.util.Scanner; public class Warms { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int WarmsGroup[] = new int[n]; for (int i = 0; i < n ; i++) { WarmsGroup[i] = sc.nextInt(); } for (int i = ...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
d62c77c1cd59dd7af5183c6801d0333f
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Scanner sc = new Scanner(System.in); int i,j,n,t,m; n = sc.nextInt(); int[] a = new...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
3cca424045da0cd9068386c06e134149
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.io.*; //PrintWriter import java.math.*; //BigInteger, BigDecimal import java.util.*; //StringTokenizer, ArrayList public class R271_Div2_B { FastReader in; PrintWriter out; public static void main(String[] args) { new R271_Div2_B().run(); } void run() { in = new FastReader(System.in...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
644ae115c63eaf250266099fc24bef3a
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.io.*; //PrintWriter import java.math.*; //BigInteger, BigDecimal import java.util.*; //StringTokenizer, ArrayList public class R271_Div2_B { FastReader in; PrintWriter out; public static void main(String[] args) { new R271_Div2_B().run(); } void run() { in = new FastReader(System.in...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
641bb4adf29b60a665504e2deacf62ed
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.io.*; //PrintWriter import java.math.*; //BigInteger, BigDecimal import java.util.*; //StringTokenizer, ArrayList public class R271_Div2_B { FastReader in; PrintWriter out; public static void main(String[] args) { new R271_Div2_B().run(); } void run() { in = new FastReader(System.in...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
30b88e9eddae970db6c1435caf0827cf
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.io.*; //PrintWriter import java.math.*; //BigInteger, BigDecimal import java.util.*; //StringTokenizer, ArrayList public class R271_Div2_B { FastReader in; PrintWriter out; public static void main(String[] args) { new R271_Div2_B().run(); } void run() { in = new FastReader(System.in...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
21d81e73e3da91e292dfad54ab022008
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.util.Scanner; import java.util.Arrays; public class main { public static void main(String args[]) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int arr[] = new int[n]; for(int i=0;i<n;i++) { arr[i] = input.nextInt(); } ...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
4164df4d47cee7f7646d70b66f735bf9
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int n= sc.nextInt(); int a; int temp=0; int result[] = new int[1000001]; for(int i=0;i<n;i++){ a=sc.nextInt(); for(int j=0;j<a;j++) result[temp++]=i+1; } int m=sc.nextInt(); //for(int ...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output
PASSED
049585d55e886b1df07a98c72e5dbd9b
train_002.jsonl
1412609400
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers ...
256 megabytes
import java.util.*; public class Worms { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int p = scanner.nextInt(); int[] piles = new int[p]; int[] nums = new int[p+1]; for(int i = 0; i < p; ++i) { piles[i] = scanner.nextInt(); nums[i+1] = nums[i]+piles[i]; ...
Java
["5\n2 7 3 4 9\n3\n1 25 11"]
1 second
["1\n5\n3"]
NoteFor the sample input: The worms with labels from [1, 2] are in the first pile. The worms with labels from [3, 9] are in the second pile. The worms with labels from [10, 12] are in the third pile. The worms with labels from [13, 16] are in the fourth pile. The worms with labels from [17, 25] are in the fifth pi...
Java 7
standard input
[ "binary search", "implementation" ]
10f4fc5cc2fcec02ebfb7f34d83debac
The first line contains a single integer n (1 ≀ n ≀ 105), the number of piles. The second line contains n integers a1, a2, ..., an (1 ≀ ai ≀ 103, a1 + a2 + ... + an ≀ 106), where ai is the number of worms in the i-th pile. The third line contains single integer m (1 ≀ m ≀ 105), the number of juicy worms said by Marmot....
1,200
Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.
standard output