You are given two arrays $$$a_1, a_2, \ldots, a_n$$$ and $$$b_1, b_2, \ldots, b_n$$$ of length $$$n$$$.
For a permutation $$$p_1, p_2, \ldots, p_n$$$ of $$$(1, 2, \ldots, n)$$$, let's define the score $$$S(p)$$$ of $$$p$$$ as follows.
There are $$$n!$$$ permutations of $$$p$$$ of $$$(1, 2, \ldots, n)$$$. Find the sum, modulo $$$10^9+7$$$, of the scores of those permutations.
A permutation is a sequence of $$$n$$$ integers from $$$1$$$ to $$$n$$$, in which all numbers occur exactly once. For example, $$$[1], [3,5,2,1,4], [1,3,2]$$$ are permutations, and $$$[2,3,2], [4,3,1], [0]$$$ are not.
The first line of the input contains an integer $$$n$$$ $$$(1\le n \le 10^5)$$$ — the length of the array.
The second line of the input contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ $$$(1 \le a_i \le 10^5)$$$ — the elements of the array $$$a$$$.
The third line of the input contains $$$n$$$ integers $$$b_1,b_2,\ldots,b_n$$$ $$$(1 \le b_i \le 10^5)$$$ — the elements of the array $$$b$$$.
Print the sum of the scores, modulo $$$10^9+7$$$, for all permutations of length $$$n$$$.
3 1 2 3 1 2 3
24
3 2 2 2 3 4 4
78
In the first case, all of the permutations of the array $$$a$$$ are $$$[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]$$$ and the scores are $$$[0, 2, 6, 6, 6, 4]$$$. respectively. So, the result is $$$0+2+6+6+6+4=24$$$.
You are given two arrays $$$a_1, a_2, \ldots, a_n$$$ and $$$b_1, b_2, \ldots, b_n$$$ of length $$$n$$$.
For a permutation $$$p_1, p_2, \ldots, p_n$$$ of $$$(1, 2, \ldots, n)$$$, let's define the score $$$S(p)$$$ of $$$p$$$ as follows.
There are $$$n!$$$ permutations of $$$p$$$ of $$$(1, 2, \ldots, n)$$$. Find the sum, modulo $$$10^9+7$$$, of the scores of those permutations.
A permutation is a sequence of $$$n$$$ integers from $$$1$$$ to $$$n$$$, in which all numbers occur exactly once. For example, $$$[1], [3,5,2,1,4], [1,3,2]$$$ are permutations, and $$$[2,3,2], [4,3,1], [0]$$$ are not.
The first line of the input contains an integer $$$n$$$ $$$(1\le n \le 16)$$$ — the length of the array.
The second line of the input contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ $$$(1 \le a_i \le 10^8)$$$ — the elements of the array $$$a$$$.
The third line of the input contains $$$n$$$ integers $$$b_1,b_2,\ldots,b_n$$$ $$$(1 \le b_i \le 10^8)$$$ — the elements of the array $$$b$$$.
Print the sum of the scores, modulo $$$10^9+7$$$, for all permutations of length $$$n$$$.
3 1 2 3 1 2 3
16
3 2 2 2 3 4 4
30
In the first case, all of the permutations of the array $$$a$$$ are $$$[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]$$$ and the scores are $$$[0, 2, 6, 2, 2, 4]$$$ respectively. So, the result is $$$0+2+6+2+2+4=16$$$.
You are given a string $$$s$$$ of length $$$n$$$ consisting of lowercase English letters.
For each index $$$i$$$, calculate what is the maximum length of the palindromic substring which includes $$$i$$$-th index.
In other words, for each index $$$i$$$, find the maximum value of $$$r - l + 1$$$ where $$$s[l\ldots r]$$$ is a palindrome and $$$(1 \le l \le i \le r \le n)$$$
Suppose s = acab. Hence, for index $$$1$$$, $$$2$$$, and $$$3$$$ the answer is $$$3$$$ (acab, the underlined part is the maximum such palindromic substring), for the index, $$$4$$$ the answer is $$$1$$$ (acab, the underlined part is the maximum such palindromic substring).
A string $$$s[1\ldots n]$$$ of length $$$n$$$ is palindromic if $$$s[i]=s[n-i+1]$$$ for every $$$1 \le i \le n$$$.
The string $$$s[l\ldots r]$$$ is a substring of string $$$s[1\ldots n]$$$ for every $$$1 \le l \le r \le n$$$.
The input data contains several test cases. The first line contains one integer $$$t$$$ $$$(1 \le t \le 10^5)$$$ — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — length of the string $$$s$$$.
The second line for each test case contains a single string, $$$s$$$ of $$$n$$$ lowercase Latin letters.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output $$$n$$$ integers — $$$i$$$-th of which is the answer for index $$$i$$$.
210astthemota9adaadaaxz
1 1 2 2 1 1 1 1 1 1 6 6 6 6 6 6 5 1 1
For the 1st test, for index: $$$3$$$ and $$$4$$$ we can select palindrome substring tt (astthemota). But for other indexes, we can't select any palindromic substring of more than $$$1$$$ length, which includes that index also.
You are given an array $$$a_1, a_2, \ldots, a_n$$$ consisting of $$$n$$$ integers.
Let's define $$$p$$$, $$$q$$$ and $$$x$$$ as follows:
Print the minimum possible value of $$$|2\cdot x - (p + q)|$$$.
Subsequence of an array can be obtained by erasing some (possibly zero or all) elements from the array. You can erase any elements, not necessarily going successively. The remaining elements preserve their order. For example, for the array $$$[5,3,1,2,4]$$$ the following arrays are subsequences: $$$[3], [5,3,1,2,4], [5,1,4]$$$, but the array $$$[1,3]$$$ is not.
The first line contains an integer $$$n$$$ $$$(1 \le n \le 500)$$$ — the length of array $$$a$$$.
The second line contains $$$n$$$ integers $$$a_1,a_2,\ldots, a_n$$$ $$$(-500 \le a_i \le 500)$$$ — elements of the array $$$a$$$.
Print the minimum possible value of $$$|2\cdot x - (p + q)|$$$.
3 3 -2 4
1
2 1 2
1
In the first case, $$$p=-2$$$ and $$$q=7$$$. Let $$$s = [-2, 4]$$$ then $$$x=-2+4=2$$$ and $$$|2\cdot x-(p+q)|=1$$$. And, this is the minimum possible answer.
Hey, I'm sure that you love to travel a lot. Now, you have $$$n$$$ cities left in your wish list, $$$i$$$-th of which costs $$$a_i$$$ to visit, and obviously, you want to visit all of them. To do so, you will follow the following steps:
Note that, you may visit one city more than once. Find the expected total cost you need to visit all the $$$n$$$ cities. It can be shown that it can be represented as $$$\frac{p}{q}$$$ where $$$p$$$ and $$$q$$$ are coprime integers and $$$q \ne 0 \bmod{10^9+7}$$$. Print the value of $$$p \cdot q^{-1} \bmod{10^9+7}$$$.
The first line contains a single integer $$$n$$$ $$$(1 \le n \le 10^5)$$$ — the number of cities.
The following line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ — $$$i$$$-th of which represents the costs of visiting city $$$i$$$ i.e. $$$a_i$$$ $$$(1 \le a_i \le 10^5)$$$.
Print a single integer — the expected total cost to visit all the cities written as $$$p \cdot q^{-1} \bmod{10^9+7}$$$.
3 1 2 3
11
1 5
5
You are given an undirected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. Initially, there is a single integer written on every vertex: the vertex $$$i$$$ has $$$p_i$$$ written on it.
You have to process $$$q$$$ queries of three types:
The first line contains two integers $$$n$$$ and $$$m$$$ $$$(1 \leq n, m \leq 10^{5})$$$ — the number of vertices of the graph and the number of edges of the graph.
The second line contains $$$n$$$ space-separated integers $$$p_1, p_2, \ldots, p_n$$$ — $$$p_i$$$ is the number initially written on vertex $$$i(1 \le p_i \le 10^9)$$$.
Then $$$m$$$ lines follow, the $$$i$$$-th of them contains two integers $$$a_i$$$ and $$$b_i$$$ $$$(1 \le a_i, b_i \le n, a_i \neq b_i)$$$ and means that the $$$i$$$-th edge connects vertices $$$a_i$$$ and $$$b_i$$$. It is guaranteed that the graph does not contain multi-edges.
The next line contains a single integer $$$q$$$ $$$(1 \leq q \leq 10^5)$$$ — the number of queries.
The $$$q$$$ lines follow, which describe the queries. Each line is given by one of the following formats:
For every query of the third type, print the value of $$$p_u$$$ written on the chosen vertex $$$u$$$.
7 6 4 7 3 4 3 2 1 1 2 1 5 2 4 2 5 3 6 3 7 6 3 1 1 1 1 2 3 1 2 7 10 3 3
7 4 10
In the 1st test, the initial graph is,
For the 1st query, vertex 1,2,4,5 are reachable from vertex-1 and the largest value is 7, written on vertex-2.
For the 2nd and 3rd queries, we delete the 1st, and 2nd edge. Then the updated graph is,
In the 4th query, the largest value is 4 found on vertex-1, which is the only node reachable from vertex-1.
In the 5th query, the updated value of vertex-6 is 10.
In the 6th query, the largest value is 10 found on vertex-6.
You are given $$$n$$$ points on a plane. The coordinates of the $$$i$$$-th point are $$$(x_i, y_i)$$$.
Print the minimum possible area of a square whose sides are parallel to the $$$x$$$ and $$$y$$$ axis, and cover all of the points.
The input data contains several test cases. The first line contains one integer $$$t$$$ $$$(1 \le t \le 10^5)$$$ — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the number of points.
Then $$$n$$$ lines follow, each line containing two integers $$$x_i$$$ and $$$y_i$$$ $$$(|x_i|, |y_i| \le 10^9)$$$ — the coordinates of $$$i$$$-th point.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, print a single integer — the minimum possible area of the square.
241 0-1 00 10 -132 0-2 00 2
4 16
You are given an array $$$a_1, a_2, \ldots, a_n$$$ of length $$$n$$$, you need to find $$${\displaystyle\max_{1 \le i \lt j \lt k \le n}{a_i\cdot a_j \cdot a_k}}$$$
The first line contains an integer $$$t$$$ $$$(1\le t\le 10^5)$$$ — the number of test cases.
The first line of each test case contains an integer $$$n$$$ $$$(3\le n \le 10^5)$$$ — the length of the array.
The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ $$$(|a_i| \le 10^6)$$$ — the elements of the array.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$.
For each test, print the answer in a single line.
24-2 0 1 235 1 -3
0 -15
You are given an integer $$$n$$$. You have to count the number of possible tuples $$$(a,b,c)$$$ such that $$$a \le b \le c$$$ and $$$a^2 + b^2 = c^2$$$ where $$$1 \le a \le n$$$.
The first line contains the number $$$t$$$ $$$(1 \le t \le 10^5)$$$ — the number of test cases.
Each of the following $$$t$$$ lines contains one integer $$$n$$$ $$$(1 \le n \le 10^5)$$$.
Print the number of possible tuples $$$(a,b,c)$$$ such that $$$a \le b \le c$$$ and $$$a^2 + b^2 = c^2$$$ where $$$1 \le a \le n$$$.
3121315
11 12 16
For test case 2, the expected tuples are listed below:
Are you hear the name Team_Robust ? It's a programming contest team from Barisal University, Bangladesh.They have done an excellent job in any recent onsite contest.
But unfortunately, this team will not participate in any new onsite contests. Are you sad to hear that? Me also. 😢
Just print the best team name of Barisal University.
Print the best team name of Barisal University.