The author's solution
Div-2. 124B - Permutations
The author's solution
Div-1. 123A - Prime Permutation
Div-2. 124C - Prime Permutation
Let's find the symbol which occurs the most and try to place the symbol on the position in which the characters have to be equal. If this symbol for all positions is not enough then the answer will be "NO", otherwise arrange the remaining characters by any way at other positions.
The author's solution
Div-1. 123B - Squares
Div-2. 124D - Squares
Let's transform the coordinates of the initial and final cells as described rule above. Then find sectors which contain our cells and calculate answer with formula above.
The author's solution
Div-1. 123C - Brackets
Div-2. 124E - Brackets
Let's iterate through the positions, starting with the highest priority. Let's put in this position the bracket "(" and consider how many ways can complete the remaining brackets to get the correct bracket sequence. If the number of ways of not less than k, then leave in this position "(", or reduce the k on the number of ways and put in this positions bracket ")". And so let's iterate through all items. In order to calculate the number of ways each time dynamics is calculated on two parameters fi, j, where i is the number of processed positions, and j is the number of opened brackets. If the position of i + 1 bracket is not defined yet then you can go to fi + 1, j + 1 or fi + 1, j - 1, if defined then only fi + 1, j + 1 or only fi + 1, j - 1, depending on opening or closing bracket respectively.
The author's solution
Div-1. 123D - String
The author's solution
Div-1. 123E - Maze
Let's run dfs and consider of the vertex as exit vertex. Then, if in some subtree defined entrance, the expected value equal to the size of the subtree. Calculate how much of each subtree is the number of entrance and calculate the number of moves, if the exit is in the current vertex. It is necessary not to forget to count cases where the current vertex is an exit and entrance is higher in the tree traversal.
The author's solution