Professional Documents
Culture Documents
2020 Preliminary 1
https://toph.co/c/intra-sust-2020-preliminary-1
Schedule
The contest will run for 2h30m0s.
Authors
The authors of this contest are anis028, Apu_hasan, arnab0sust, avivilla, foyaz05,
humayan7711, jubair_123, manetsus, Maruf_75, mridul_sust, ovis96, Rajan_sust,
saif_sust, shahriarsust13, shourov.sust, and Wiz_Khalipha.
Rules
This contest is formatted as per the official rules of ICPC Regional Programming
Contests.
You can use Bash 5.0, Brainf*ck, C# Mono 6.0, C++11 GCC 7.4, C++14 GCC 8.3, C++17 GCC
9.2, C11 GCC 9.2, Common Lisp SBCL 2.0, Erlang 22.3, Free Pascal 3.0, Go 1.13, Haskell
8.6, Java 1.8, Kotlin 1.1, Node.js 10.16, Perl 5.30, PHP 7.2, PyPy 7.1 (2.7), PyPy 7.1 (3.6),
Python 2.7, Python 3.7, Ruby 2.6, and Whitespace in this contest.
Notes
There are 6 challenges in this contest.
If you find any discrepencies between the printed copy and the problem statements in
Toph Arena, please rely on the later.
Input
First line will contain number of test case T. Each subsequent line will contain a number
N.
1 ≤ T ≤ 1000
1≤N≤
Output
For each test case output one integer. Number of atomic pair for N.
Samples
Input Output
1 3
2
Since this is called A4, maybe you can guess this is a part of a series of A papers. Yes, you
are right ! The paper with 1 square meter of area is called A0. If you cut this into half, you’ll
get two A1 papers. And from one A1 you’ll get two A2, from one A2, you’ll get two A3,
from one A3, you’ll get two A4 and so on… Please refer to the figure to clearly
understand how you should make the cuts. So, now you know the story behind the so
familiar name A4.
We want to make a name to size calculator. And you can now forget the traditional size
of an A0 paper (1 square meter area). This may vary now.
You are given the width ( ) of an paper in centimeters. You need to find the sum
of the dimensions (in centimeters) of an paper.
Input
The input starts with an integer T (T ≤ 100 ) denoting the number of test cases.
Each of the next T lines contains three integers m, and n (0 ≤ n ≤ m ≤ 70, 1 ≤ ≤
1000 ).
Output
For each case, output a single line containing a floating point number denoting the sum
of the width and the height of an paper. Print exactly 4 digits after decimal point.
Samples
Input Output
2 102.4264
3 15 0 168.9949
5 35 3
More formally suppose the grid size is , which means the grid has rows and
columns.
For every row i, 1 ≤ i ≤ n, let is the set of all values in the row i then = m (size of
is m). Similarly, for every column j, 1 ≤ j ≤ m, let is the set of all values in the
column j then = n.
But this was Kiny’s rectangle before last night. Yesterday night, Kiny suddenly woke up
by the barking of the street dog near his house. He assumes that someone (thief)
entered his room and shuffled his rectangle. So that the order of the rectangle is not the
same as before. For this, the main specialty of the grid might be lost. But he is desperate
to have its specialty back. So he came to you to solve his problem.
Input
The first line will contain T ( number of test cases, T ≤ ). For each test case there will
be n m ( which means the grid has n rows and m colums, ≤ ) and for following
n lines, each will contain m numbers (1 ≤ each number ≤ ) describing the grid. As
mentioned earlier in the problem, this grid might have lost its speciality.
Output
For each test case output n lines, for each n lines there will be m integers which indicates
the special rectangle. There can be multiple possible solutions, any of them would be
enough.
Samples
Input Output
1 2 3
2 2 4 2
2 2
3 4
We expect a third vector from you. And you have to make sure 2 properties
of .
Input
The first line will contain an integer ( ) denoting the number of test
cases. For each test case there will be exactly one line that contains four integers
Output
Print and in a line for each test case. It is guaranteed that and will be integers.
Samples
Input Output
2 0 10
2 0 0 5 0 -2
1 1 -1 -1
Input
First-line there is a number ( ). Each of the next N-1 lines contains two
integers u and v (1 ≤ u,v ≤ n, u≠v), denoting an edge connecting vertex u and vertex v.
Next line contains N integers . The first element is the cost of city number
1, the second element is the cost of city number 2 city and so on.
(1 ≤ ≤ 2047, 1 ≤ i ≤ N)
Output
Output one integer, the maximum overall cost.
Samples
Input Output
3 7
1 2
1 3
1 2 4
Beauty of a character is the sum of positions of that character in the string. For example,
beauty of ‘a’ in the string “bacbdeba” is , becuase the positions of ‘a’ in the
string are and . Beauty of a subsequence is the sum of beauties of the characters in
the subsequence. For example, the beauty of the subsequence “aa” of string “bacbdeba”
is .
1. If you include a character to a subsequence, you should include all of its occurences.
For example, for the string “bacbdeba”, “babba” can be beautiful (if it obeys the other
condition), but “ba” can not be. Because, if ‘b’ is chosen to be in the subsequence, all
occurrences of ‘b’ in the string should be in the subsequence, same for ‘a’.
2. Beauty of the subsequence should be at least M.
You are given a string of length N. Can you find how many beautiful subsequences can be
derived from the string?
Input
The first line of the input contains two integers and . The next line contains the
string. The string contains lowercase English letters (‘a’ to ‘z’ ) and digits (‘0’ to ‘9’ ).
Output
Print an integer in a single line denoting the number of beautiful subsequences.
Input Output
3 5 2
a1a