Given three integers $$$a$$$, $$$b$$$, $$$c$$$, write the lexicographically smallest palindrome with $$$a$$$ 'A's, $$$b$$$ 'B's, and $$$c$$$ 'C's. If no palindrome can be formed with that number of letters, write 'ROP'.
The input starts with an integer $$$t$$$ indicating the number of test cases. Each case contains a line with three integers $$$a$$$, $$$b$$$, and $$$c$$$.
For each case, output a line with the answer.
$$$0 \leq a, b, c \leq 1000$$$
$$$t \leq 1000$$$
At least one of the integers is different from $$$0$$$.
14 points: Two of the integers are $$$0$$$.
27 points: All integers are even.
59 points: No additional conditions.
4 1 0 0 2 2 2 2 0 3 1 3 5
A ABCCBA ACCCA ROP
Pedro wants to send an SMS to his parents. Since he doesn't have much balance left, he has decided to eliminate spaces. By doing this, he has a message of $$$n$$$ letters, but he only has enough balance to pay for $$$k$$$ letters, with $$$k \leq n$$$.
Pedro wants to delete letters, without altering the order of the others, in such a way that the final message is the lexicographically smallest possible with $$$k$$$ letters.
Given $$$n$$$, $$$k$$$, and the message, help Pedro reduce the message.
The input starts with an integer $$$t$$$, the number of cases. Each case consists of a line with the integers $$$n$$$ and $$$k$$$, followed by another line with the original message of $$$n$$$ letters, all of which are lowercase.
For each case, write a line with the final message.
$$$1 \leq k \leq n \leq 100000$$$
$$$t \leq 100$$$
1 point: $$$k = n$$$
3 points: $$$k = 1$$$
5 points: $$$k = 2$$$
10 points: $$$k \leq 10$$$
3 points: $$$k = n-1$$$
5 points: $$$k = n-2$$$
10 points: $$$k \geq n-10$$$
30 points: $$$n \leq 100$$$
33 points: $$$n \leq 100000$$$
4 4 1 yxwv 9 8 tqbjtqmif 10 5 eatqvgjpog 10 8 tpoudnqtob
v qbjtqmif agjog oudnqtob
We all know that Jan loves cookies. Right now, Jan has piles of different types of cookies in front of him: chocolate, lemon, coconut, pretzels, crackers, biscotti, macarons, lebkuchen, stroopwafels... Like any cookie lover, he wants to eat the maximum number of different types of cookies, but he has a problem: there are other people who also want to eat them. For each cookie, Jan knows what type it is and the moment someone will eat it if he doesn't do so first. The good news is that Jan can eat an unlimited number of cookies (he can even take several of the same type) and he eats them instantly. The bad news is that between two consecutive cookies, he must rest for a time proportional to the number of cookies he has eaten up to that moment. If Jan eats the first cookie at time $$$t$$$, he must wait until time $$$t+1$$$ to eat the second one. If he eats the second one at time $$$t$$$, he must wait until time $$$t+2$$$ to eat the third one. And in general, if he eats the $$$k$$$-th one at time $$$t$$$, he must wait until time $$$t+k$$$ to eat the next one.
Jan wants to eat the maximum number of different types of cookies, and your goal is to tell him what that maximum is. Nevertheless, note that Jan can eat as many cookies as he wants of the same type. Initially, Jan has an empty stomach and can eat the first cookie without having to wait. Additionally, if a cookie is going to disappear at time $$$t$$$, Jan can eat it up until that very moment $$$t$$$ (if necessary, he will snatch it from the hands of the person who was going to eat it).
The input starts with an integer $$$t$$$, the number of cases. It is followed by two integers $$$m, n$$$, the number of types of cookies and the number of cookies, respectively. Next, the $$$n$$$ cookies are described. Each one is described by two integers, $$$a_i, t_i$$$. The first indicates the type of cookie and the second the moment when the cookie will disappear if Jan does not eat it first.
Print $$$t$$$ lines, each with a single integer: the maximum number of distinct types of cookies that Jan can eat.
For all cases $$$t \leq 40$$$, $$$m \leq n$$$ and $$$1 \leq a_i \leq m$$$. Additionally, for any number between $$$1$$$ and $$$m$$$, there will be at least one cookie of that type.
Case 1: $$$ m \leq 10$$$, $$$n \leq 100$$$, $$$t_i \leq 1000$$$ (15 points)
Case 2: $$$ m \leq 10$$$, $$$n \leq 1000$$$, $$$t_i \leq 1000000$$$ (15 points)
Case 3: $$$ m \leq 100$$$, $$$n = m$$$, $$$t_i \leq 10000$$$ (20 points)
Case 4: $$$ m \leq 100000$$$, $$$n = m$$$, $$$t_i \leq 10^9$$$ (25 points)
Case 5: $$$ m \leq 50000$$$, $$$n \leq 200000$$$, $$$t_i \leq 10^9$$$ (25 points)
2 2 4 1 1 1 2 1 3 2 4 3 3 1 2 2 2 3 2
2 2
Consider the grid $$$\mathbb{Z}^k$$$, that is, the set of points of the form $$$(a_1, \dots, a_k)$$$ with $$$a_i$$$ being integers. For example, for $$$k=2$$$, this is the usual grid one would find on an infinitely extended graph paper. Given an $$$n$$$, the task is to calculate the number of paths that start from the origin and return to it in $$$2n$$$ steps, where each move consists of adding or subtracting one to any of the coordinates. The result should be given modulo $$$998244353$$$.
The input consists of multiple cases. The first line will contain a natural number $$$t$$$, the number of cases.
Each case will consist of a line with the integers $$$n$$$ and $$$k$$$ separated by a space.
The output should be a natural number for each case, representing the number of distinct paths that return to the origin modulo $$$998244353$$$.
$$$1 \leq t \leq 200000$$$
21 points: $$$1 \leq n \leq 10^5$$$, $$$k = 1$$$
12 points: $$$1 \leq n \leq 30$$$, $$$k \leq 5$$$
43 points: $$$1 \leq n \leq 100$$$, $$$k \leq 100$$$
24 points: $$$1 \leq n \leq 10^5$$$, $$$k \leq 2$$$
3 1 2 10 1 10 3
4 184756 975531138